home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2005 October / PCWOCT05.iso / Software / FromTheMag / Syn Text Editor 2.1.0.46 / synsetup-2.1.0.46.exe / {app} / templates / Pascal / Pascal GUI.pas < prev    next >
Pascal/Delphi Source File  |  2003-08-13  |  2KB  |  80 lines

  1. {Description: Pascal GUI Program|}
  2. {
  3.   Created: {$DateTime} by {$UserName}
  4.  
  5.   $Id: Pascal\040GUI.pas,v 1.1.2.3 2003/08/13 00:38:45 neum Exp $
  6. }
  7.  
  8. program {$FileTitleNoExt};
  9. {$APPTYPE GUI}
  10.  
  11. uses
  12.   { If you're using Delphi add the Messages Unit to your Uses clause }
  13.   Windows,
  14.   SysUtils;
  15.  
  16. var
  17.   { Global Variables }
  18.   WClass: TWndClass;
  19.   Handle: HWND;         { Handle of the Mainwindow }
  20.   Msg: TMsg;
  21.  
  22. const
  23.   AppTitle = '{$FileTitleNoExt}';
  24.   ClassName = '{$FileTitleNoExt}WindowClass';
  25.   
  26. function WndProc(HWnd: HWND; Msg: UINT; wParam: WPARAM; lParam: LPARAM): LRESULT; stdcall;
  27. begin
  28.   { Window procedure, add here your message handlers }
  29.   case Msg of
  30.     WM_DESTROY:
  31.       begin
  32.         PostQuitMessage(0);
  33.         WndProc := 0;
  34.       end;
  35.     WM_COMMAND:
  36.       begin
  37.         { To Do: Add your command Message handlers here }
  38.       end;
  39.     { To Do: Add other Message handlers here }
  40.     else
  41.       WndProc := DefWindowProc(HWnd, Msg, WParam, LParam);
  42.   end;
  43. end;
  44.  
  45. procedure ProcessMessages;
  46. begin
  47.   { Wait for Messages }
  48.   while GetMessage(Msg, 0, 0, 0) do begin
  49.     TranslateMessage(Msg);
  50.     DispatchMessage(Msg);
  51.   end;
  52. end;
  53.  
  54. begin
  55.   with WClass do begin
  56.     Style := CS_HREDRAW or CS_VREDRAW;
  57.     lpfnWndProc := @WndProc;
  58.     cbClsExtra := 0;
  59.     cbWndExtra := 0;
  60.     hInstance := HInstance;
  61.     hIcon := LoadIcon(0, IDI_APPLICATION);
  62.     hCursor := LoadCursor(0, IDC_ARROW);
  63.     hbrBackground := COLOR_WINDOW + 1;
  64.     lpszMenuName := PChar(AppTitle);
  65.     lpszClassName := PChar(ClassName);
  66.   end;
  67.   RegisterClass(WClass);
  68.   Handle := CreateWindow(PChar(ClassName), PChar(AppTitle), WS_OVERLAPPEDWINDOW, 0,
  69.     0, 100, 100, 0, 0, HInstance, nil);
  70.   if Handle = 0 then begin
  71.     MessageBox(0, 'Unable to create Window.', PChar(AppTitle), MB_ICONSTOP + MB_OK);
  72.   end else begin
  73.     { Add here your other initialization stuff here }
  74.     ShowWindow(Handle, SW_SHOW);
  75.     ProcessMessages;
  76.     DestroyWindow(Handle);
  77.   end;
  78. end.
  79.  
  80.